<template>
  <pageTabelLayout>
    <template #pageHeader>
      <div class="search-form divClass" v-if="headerShow">
        <div>
          <a-form
            size="small"
            ref="formRef"
            :model="pageData"
            layout="inline"
            label-align="right"
            v-if="
              permissionStore.hasPermisson('zjpg.wzjcx') ||
              permissionStore.hasPermisson('zjpg.yzjcx')
            "
          >
            <a-form-item label="楼层" v-if="tableId != 3">
              <a-input
                allow-clear
                :style="{ width: '200px' }"
                class="bacClass"
                placeholder=""
                v-model="pageData.storey"
                @press-enter="huiche"
              />
            </a-form-item>

            <a-form-item
              label="指派日期"
              field="date"
              :rules="[{ required: true, message: '指派日期必填' }]"
              v-if="tableId == 1"
              :validate-trigger="['change', 'blur']"
            >
              <a-date-picker
                popup-container="html"
                :style="{ width: '200px' }"
                class="bacClass"
                v-model="pageData.date"
                @press-enter="huiche"
              />
            </a-form-item>
            <a-form-item
              label="班次"
              field="shift"
              :rules="[{ required: true, message: '班次必填' }]"
              v-if="tableId == 1"
              :validate-trigger="['change', 'blur']"
            >
              <a-select
                popup-container="html"
                allow-clear
                :style="{ width: '200px' }"
                class="bacClass"
                placeholder=""
                v-model="pageData.shift"
                @press-enter="huiche"
              >
                <a-option value="0">白班</a-option>
                <a-option value="1">晚班</a-option>
              </a-select>
            </a-form-item>
            <a-form-item label="指派日期" field="date" v-if="tableId == 2">
              <a-date-picker
                popup-container="html"
                :style="{ width: '200px' }"
                class="bacClass"
                v-model="pageData.date3"
                @press-enter="huiche"
              />
            </a-form-item>
            <a-form-item label-col-flex="52px" label="班次" field="shift" v-if="tableId == 2">
              <a-select
                popup-container="html"
                allow-clear
                :style="{ width: '200px' }"
                class="bacClass"
                placeholder=""
                v-model="pageData.shift3"
                @press-enter="huiche"
              >
                <a-option value="0">白班</a-option>
                <a-option value="1">晚班</a-option>
              </a-select>
            </a-form-item>
            <a-form-item label="员工" field="EmpId" v-if="tableId == 2">
              <a-select
                popup-container="html"
                allow-clear
                class="bacClass"
                placeholder=""
                :style="{ width: '200px' }"
                v-model="pageData.EmpId"
                @focus="getUsers"
                @press-enter="huiche"
              >
                <a-option v-for="(item, index) in pageData.EmpList" :value="item['id']">{{
                  item['name']
                }}</a-option>
              </a-select>
            </a-form-item>
          </a-form>
        </div>
      </div>
      <div class="my-divisders">
        <a-divider orientation="center">
          <icon-double-up
            v-if="headerShow"
            @click="headerShow = false"
            :strokeWidth="2"
            :size="18"
          />
          <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
        </a-divider>
      </div>
      <div class="my-tool-bar">
        <Toolbar
          :items="pageData.btnList"
          @select="selectHandler"
          @dispatch="handleClick"
          @rejected="rejecteds"
        >
        </Toolbar>
      </div>
    </template>
    <template #pageTabel>
      <!-- <a-space style="float: right; margin-right: -20px; z-index: 100">
        <div class="my-tool-bar" style="text-align: right; margin-bottom: -40px; z-index: 100">
          <a-button type="primary" size="small" @click="selectHandler"
            style="margin-right: 10px; z-index: 100; cursor: pointer"
            v-if="permissionStore.hasPermisson('zjpg.wzjcx') || permissionStore.hasPermisson('zjpg.yzjcx')">查询
          </a-button>
          <span v-if="tableId == 1">
            <a-button type="primary" size="small" @click="handleClick" style="cursor: pointer; z-index: 100"
              v-if="permissionStore.hasPermisson('zjpg.pg') && pageData.dutymachineState == 0">派工
            </a-button>
          </span>
        </div>
      </a-space> -->

      <a-tabs
        :lazy-load="true"
        :justify="true"
        @change="changeTabs"
        :default-active-key="pageData1.tableIndex"
      >
        <a-tab-pane title="未值机" key="1">
          <a-spin
            :loading="pageData.pageLoading"
            tip="加载中"
            dot
            style="height: 100%; width: 100%; z-index: 999"
          >
            <AgGridVuesCopys
              :rowHeight="33"
              :headerHeight="33"
              :suppressCopyRowsToClipboard="true"
              :suppressDragLeaveHidesColumns="true"
              rowSelection="multiple"
              @grid-ready="gridReady"
              @columnResized="onColumnResized"
              @columnMoved="onColumnMoved"
              @columnVisible="onColumnVisible"
              @SelectionChanged="aggridFs.clickAllSelectors"
              @FilterChanged="aggridFs.onFilterChanged"
              style="height: calc(100% - 45px)"
              :defaultColDef="defaultColDef22"
              class="ag-theme-alpine"
              :rowData="table.dataList"
              :columnDefs="tc1"
              :localeText="localeText1"
            >
            </AgGridVuesCopys>
            <paginationCopys
              v-if="tableId == 1"
              :total="pagination.total"
              show-total
              show-jumper
              show-page-size
              :page-size="pagination.pageSize"
              :current="pagination.page"
              @change="PageSize"
              @page-size-change="change1"
              style="justify-content: center"
              :page-size-options="pagingList1"
            />
          </a-spin>
        </a-tab-pane>
        <a-tab-pane title="已值机" key="2">
          <a-spin
            :loading="pageData.pageLoading"
            tip="加载中"
            dot
            style="height: 100%; width: 100%; z-index: 999"
          >
            <AgGridVuesCopys
              :rowHeight="33"
              :headerHeight="33"
              :suppressCopyRowsToClipboard="true"
              :suppressDragLeaveHidesColumns="true"
              rowSelection="multiple"
              @grid-ready="gridReady2"
              @columnResized="onColumnResized2"
              @columnMoved="onColumnMoved2"
              @columnVisible="onColumnVisible2"
              @SelectionChanged="aggridFs1.clickAllSelectors"
              @FilterChanged="aggridFs1.onFilterChanged"
              style="height: calc(100% - 45px)"
              :defaultColDef="defaultColDef"
              class="ag-theme-alpine"
              :rowData="table.dataList"
              :columnDefs="tc2"
              :localeText="localeText1"
            >
            </AgGridVuesCopys>
            <paginationCopys
              v-if="tableId == 2"
              :total="paginations.total"
              show-total
              show-jumper
              show-page-size
              :page-size="paginations.pageSize"
              :current="paginations.page"
              @change="PageSize"
              @page-size-change="change1"
              style="justify-content: center"
              :page-size-options="pagingList1"
            />
          </a-spin>
        </a-tab-pane>
      </a-tabs>
    </template>

    <a-modal
      style="z-index: 999"
      ok-text="保存"
      cancel-text="关闭"
      :drawer-style="{ zIndex: 999 }"
      :mask-closable="false"
      width="1200px"
      :visible="pageData.showAdd"
      @ok="sideOk"
      @cancel="pageData.showAdd = false"
    >
      <template #title>
        {{ pageData.sideTitle }}
      </template>
      <!-- <template #footer>
        <a-button @click="pageData.showAdd = false">
          关闭
        </a-button>
        <a-button type="primary" @click="sideOk" v-if="pageData.sideTitle != '详情'">
          {{ pageData.sideTitle == '修改' ? "保存" : "确认" }}
        </a-button>
      </template> -->
      <div style="display: flex; height: 600px">
        <div style="flex: 2; margin-right: 10px; height: 600px">
          <a-card title="机台信息" style="height: 600px">
            <AgGridVuesCopys
              :rowHeight="33"
              :headerHeight="33"
              :suppressCopyRowsToClipboard="true"
              rowSelection="multiple"
              @grid-ready="gridReady3"
              style="height: 520px"
              :defaultColDef="defaultColDef3"
              class="ag-theme-alpine"
              :rowData="pageData.dataList3"
              :columnDefs="tc3"
              :localeText="localeText1"
            >
            </AgGridVuesCopys>
          </a-card>
        </div>
        <div style="flex: 1">
          <a-card title="请指派日期及人员">
            <a-form size="small" :model="pageData" layout="inline" label-align="right">
              <a-form-item label="指派日期" label-col-flex="80px">
                <div style="width: 100px">{{ pageData.date2 }}</div>
              </a-form-item>
              <a-form-item label="班次" label-col-flex="80px">
                <div style="width: 100px">{{ pageData.shift == 0 ? '白班' : '晚班' }}</div>
                <!-- <div style="width: 100px;">{{ pageData.shift2 == 0 ? '白班' : '晚班' }}</div> -->
              </a-form-item>
              <a-form-item label-col-flex="80px" label="部门">
                <a-cascader
                  v-model="dataForm.departmentId"
                  :options="pageData.EmpList"
                  allow-clear
                  ref="casOb1"
                  style="width: 240px"
                  :class="{ bacClass: pageData.sideTitle != '详情' }"
                  :disabled="pageData.sideTitle == '详情'"
                  @change="cascaderChange1($event)"
                  :title="pageData.title1"
                  popup-container="html"
                />
              </a-form-item>
              <!-- <a-form-item label="员工" field="baiEmpId" :rules="[{ required: true, message: '员工必填' }]"
                label-col-flex="80px" :validate-trigger="['change', 'blur']">
                <a-select popup-container="html"  allow-clear :class="{ 'bacClass': pageData.sideTitle == '修改' }" placeholder=""
                  style="width: 228px;" v-model="pageData.baiEmpId" :disabled="dataForm.departmentId == ''"
                  @focus="getUsers">
                  <a-option v-for="(item, index) in pageData.EmpList" :value="item['id']">{{ item['name'] }}</a-option>
                </a-select>
              </a-form-item> -->
              <a-form-item label="员工" label-col-flex="80px">
                <a-select
                  popup-container="html"
                  allow-clear
                  :class="{ bacClass: pageData.sideTitle != '详情' || dataForm.departmentId != '' }"
                  placeholder=""
                  :disabled="pageData.sideTitle == '详情' || dataForm.departmentId == ''"
                  style="width: 240px"
                  v-model="pageData.empName"
                  @change="changeEmp"
                  @focus="getUsers1"
                >
                  <a-option v-for="(item, index) in pageData.EmpList1" :value="item['name']">{{
                    item['name']
                  }}</a-option>
                </a-select>
              </a-form-item>
            </a-form>
          </a-card>
        </div>
      </div>
    </a-modal>

    <a-modal
      :visible="pageData.showAddZJ"
      title="值机派工"
      @cancel="handleCancel"
      :draggable="true"
      width="1200px"
      :ok-loading="pageData.pageLoading"
      style="z-index: 999"
      @ok="saveZjData"
    >
      <div style="display: flex; height: 600px">
        <div style="flex: 2; margin-right: 10px; height: 600px">
          <a-card title="机台信息" style="height: 600px">
            <AgGridVuesCopys
              :rowHeight="33"
              :headerHeight="33"
              :suppressCopyRowsToClipboard="true"
              rowSelection="multiple"
              @grid-ready="gridReady3"
              style="height: 520px"
              :defaultColDef="defaultColDef3"
              class="ag-theme-alpine"
              :rowData="pageData.dataList3"
              :columnDefs="tc3"
              :localeText="localeText1"
            >
            </AgGridVuesCopys>
          </a-card>
        </div>
        <div style="flex: 1">
          <a-card title="请指派日期及人员">
            <a-form
              ref="formRef2"
              size="small"
              :model="pageData"
              layout="inline"
              label-align="right"
            >
              <a-form-item label="指派日期" label-col-flex="80px">
                <div style="width: 100px">{{ pageData.date }}</div>
              </a-form-item>
              <a-form-item label="班次" label-col-flex="80px">
                <div style="width: 100px">{{ pageData.shift == 0 ? '白班' : '晚班' }}</div>
              </a-form-item>
              <a-form-item label-col-flex="80px" label="部门" field="departmentId">
                <a-cascader
                  v-model="dataForm.departmentId"
                  :options="pageData.EmpList"
                  allow-clear
                  ref="casOb1"
                  style="width: 240px"
                  class="bacClass"
                  @change="cascaderChange1($event)"
                  :title="pageData.title1"
                  popup-container="html"
                />
              </a-form-item>
              <!-- <a-form-item label="员工" field="baiEmpId" :rules="[{ required: true, message: '员工必填' }]"
                label-col-flex="80px" :validate-trigger="['change', 'blur']">
                <a-select popup-container="html"  allow-clear :class="{ 'bacClass': pageData.sideTitle == '修改' }" placeholder=""
                  style="width: 228px;" v-model="pageData.baiEmpId" :disabled="dataForm.departmentId == ''"
                  @focus="getUsers">
                  <a-option v-for="(item, index) in pageData.EmpList" :value="item['id']">{{ item['name'] }}</a-option>
                </a-select>
              </a-form-item> -->
              <a-form-item
                label="员工"
                field="baiEmpId"
                :rules="[{ required: true, message: '员工必填' }]"
                label-col-flex="80px"
                :validate-trigger="['change', 'blur']"
              >
                <a-select
                  popup-container="html"
                  allow-clear
                  allow-search
                  class="bacClass"
                  placeholder=""
                  style="width: 228px"
                  v-model="pageData.empName"
                  @change="changeEmp"
                  @focus="getUsers1"
                >
                  <a-option v-for="(item, index) in pageData.EmpList1" :value="item['name']">{{
                    item['name']
                  }}</a-option>
                </a-select>
              </a-form-item>
            </a-form>
          </a-card>
        </div>
      </div>
      <template #footer>
        <a-button
          type="primary"
          size="small"
          @click="saveZjData"
          v-if="permissionStore.hasPermisson('zjpg.pg')"
          >保存
        </a-button>
      </template>
    </a-modal>
    <a-modal
      v-model:visible="visible1"
      title="温馨提示"
      @cancel="handleCancel1"
      :draggable="true"
      style="z-index: 1000"
    >
      <div style="color: red">选中的机台存在跨楼层的数据,是否继续派工？</div>
      <template #footer>
        <a-button size="small" @click="visible1 = false">关闭</a-button>
        <a-button type="primary" size="small" @click="goContinue">继续</a-button>
      </template>
    </a-modal>
    <a-modal
      v-model:visible="visible2"
      title="详情"
      @cancel="handleCancel2"
      :draggable="true"
      style="z-index: 1000"
      width="1000px"
    >
      <a-table
        stripe
        :bordered="true"
        :columns="tableColumnsXq"
        size="mini"
        :row-selection="{ showCheckedAll: true, width: 50 }"
        v-model:selected-keys="selectKeys"
        :loading="table.tableLoading"
        :data="pageData.dataList3"
        rowKey="id"
      >
      </a-table>
      <template #footer>
        <a-button size="small" @click="visible2 = false">关闭</a-button>
      </template>
    </a-modal>
  </pageTabelLayout>
</template>

<script lang="ts">
  import { post, get } from '@/api/http'
  import {
    useTable,
    useRowKey,
    useTableColumn,
    usePagination,
    useRowSelection,
  } from '@/hooks/table'
  import { ref, reactive, onMounted, onActivated, getCurrentInstance, onBeforeMount } from 'vue'
  import Toolbar from '@/components/Toolbar.vue'
  import { Form, Message, Modal } from '@arco-design/web-vue'
  import { FormInstance } from '@arco-design/web-vue/es/form'
  import emitter from '@/hooks/useEventBus'
  import validate from '@/hooks/useValidate'
  import { DatasetComponent } from 'echarts/components'
  import { AnyARecord } from 'dns'
  import { baseURL } from '../../../api/axios.config'
  import axios from 'axios'
  import { url } from 'inspector'
  import usePermission from '@/store/modules/permission'
  
  import PageTabelLayout from '@/components/pageTabelLayout.vue'
  import { localeText } from '@/api/aggridZw'
  import { pagingList } from '@/api/paging'
  import { Post } from '@/api/basedata'
  import { slicing } from '@/utils/caseFrimAndSecRig'
  import CorporateSectorCascader from '@/components/corporateSectorCascader/inde.vue'
  import { saveOrUpdateGridState as saveOrUpdateGridState01 } from '@/hooks/useGridState'
  import { saveOrUpdateGridState as saveOrUpdateGridState02 } from '@/hooks/useGridState'
  import useAgGridFilterSelector from '@/utils/aggridFilterAllSelect'
  interface ClothInfo {
    id: any
    companyId: any
    company: any
    machineCode: any
    storey: any
    empId: any
    empCode: any
    empName: any
    dutyDate: any
    shift: any
    dutyState: any
    pieceDataState: any
    createName: any
    createTime: any
    updateName: any
    updateTime: any
    departmentName: any
    departmentId: any
  }

  export default {
    name: 'CheckDispatch',
    setup() {
      const { proxy } = getCurrentInstance()
      const aggridFs = useAgGridFilterSelector()
      const aggridFs1 = useAgGridFilterSelector()
      const tabValue = ref<any>(proxy.$route.query.name)
      console.log(tabValue.value)
      const pageData1 = reactive<any>({
        tableIndex: tabValue || '1',
      })
      let cascaderRef = ref('')
      let configCascader = ref<{}>({
        corporateWidth: '400px', //公司宽度
        sectorWidth: '400px', //部门宽度
        corporateRquired: false, //公司是否必填
        sectorRquired: false, //部门是否必填
        size: 'small', //选择框大小'mini' | 'small' | 'medium' | 'large'
        corporateName: '公司', //公司label
        sectorName: '部门', //部门label
      })
      const changeCascader = (data: any) => {
        pageData.ygName = ''
        pageData.ygNameList = []
        const { corporateId, sectorId } = data
        console.log(corporateId)
        pageData.firmId = corporateId
        pageData.applyBranchId = sectorId
      }
      const headerShow = ref<boolean>(true)
      function PageSize(val: any) {
        if (tableId.value == 1) {
          pagination.page = val
          doRefresh()
        } else if (tableId.value == 2) {
          paginations.page = val
          doRefresh2()
        }
      }

      function change1(val: any) {
        if (tableId.value == 1) {
          pagination.pageSize = val
          doRefresh()
        } else if (tableId.value == 2) {
          paginations.pageSize = val
          doRefresh2()
        }
      }

      //查询 未值机
      function doRefresh() {
        formRef.value?.validate().then((err) => {
          if (!err) {
            pageData.pageLoading = true
            post({
              url: '/planSingle/dutymachine/getPageByMachine',
              data: {
                page: pagination.page,
                size: pagination.pageSize,
                deleteState: 0,
                storey: pageData.storey,
                shift: pageData.shift,
                date: pageData.date,
              },
            })
              .then(({ data, code, message }: any) => {
                if (code === 200) {
                  aggridFs.resetAgFs()
                  table.handleSuccess(data.list)
                  gridOption.value.setRowData(data.list)
                  pagination.setTotalSize(data.total)
                  console.log(data.total)
                } else {
                  Message.error({
                    content: message,
                    duration: 5000,
                  })
                }
              })
              .catch(console.log)
              .finally(() => {
                pageData.pageLoading = false
              })
          } else {
            gridOption.value.setRowData([])
          }
        })
      }
      //查询 已值机
      function doRefresh2() {
        pageData.pageLoading = true
        post({
          url: '/planSingle/dutymachineMachine/getPage',
          data: {
            page: paginations.page,
            size: paginations.pageSize,
            storey: pageData.storey,
            shift: pageData.shift3,
            dutyDate: pageData.date3,
            empId: pageData.EmpId,
          },
        })
          .then(({ data, code, message }: any) => {
            if (code === 200) {
              aggridFs1.resetAgFs()
              paginations.setTotalSize(data.total)
              table1.handleSuccess(data.list)
              gridOption2.value.setRowData(data.list)
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
            }
          })
          .catch(console.log)
          .finally(() => {
            pageData.pageLoading = false
          })
      }
      //弹窗表格查询
      function doRefresh3() {
        pageData.pageLoading = true
        post({
          url: '/planSingle/dutymachine/getListByMachineInRedis',
          data: {
            machineList: gridOption.value.getSelectedRows().map((o: any) => {
              return o.machineCode
            }),
            shift: pageData.shift,
            date: pageData.date,
          },
        })
          .then(({ data, code, message }: any) => {
            if (code === 200) {
              pageData.dataList3 = data
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
            }
          })
          .catch(console.log)
          .finally(() => {
            pageData.pageLoading = false
          })
      }

      const { selectedRowKeys, onSelectionChange } = useRowSelection()
      const selectedRowKeysChecked = useRowSelection()
      const pagination = usePagination(doRefresh)
      const paginations = usePagination(doRefresh2)

      const table = useTable()
      const table1 = useTable()
      const rowKey = useRowKey('id')
      const tableColumns = useTableColumn([
        {
          title: '公司',
          key: 'firm',
          dataIndex: 'firm',
          width: 150,
        },
        {
          title: '机台号',
          key: 'machineCode',
          dataIndex: 'machineCode',
          width: 150,
        },

        {
          title: '楼层',
          key: 'storey',
          dataIndex: 'storey',
          width: 150,
        },
        {
          title: '机台状态',
          key: 'machineState',
          dataIndex: 'machineState',
          slotName: 'machineState',
          width: 150,
        },
        {
          title: '操作',
          key: 'id',
          dataIndex: 'id',
          slotName: 'action',
          width: 150,
          // fixed: 'right',
        },
        // {
        //   title: '坯布编号',
        //   key: 'greyCode',
        //   dataIndex: 'greyCode',
        //   width: 200,
        // },

        // {
        //   title: '坯布名称',
        //   key: 'grayName',
        //   dataIndex: 'grayName',
        //   width: 1030,
        // },
      ])
      onBeforeMount(() => {})
      let tc1: any[] = tableColumns.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          width: o['width'],
          tooltipField: o.key,
        }
        if (o.slotName === 'action') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 80
          obj['cellRenderer'] = {
            template: `<el-button style="{color:isDetailDisabled?'#999':'#165dff'}"  link @click="a" :disabled="isDetailDisabled">详情</el-button>`,
            setup(props: any) {
              console.log('props', props)
              const a = () => {
                openPop2(props.params.data)
              }
              return {
                a,
                isDetailDisabled,
              }
            },
          }
        }
        if (o.slotName === 'machineState') {
          obj['resizable'] = false
          obj['sortable'] = false
          // obj['lockPosition'] = 'right'
          obj['width'] = 120
          obj['cellRenderer'] = {
            template: `<a-space> 
            <el-tag v-if="val==0">未启动</el-tag>
            <el-tag type="warning" v-if="val==1">待单</el-tag>
            <el-tag type="success" v-if="val==2">待纱</el-tag>
            <el-tag type="danger" v-if="val==3">洗转机</el-tag>
            <el-tag type="warning" v-if="val==4">运行</el-tag>
            <el-tag  v-if="val==5">暂停</el-tag>
            <el-tag type="info" v-if="val==6">维修</el-tag>
            <el-tag type="info" v-if="val==7">保养</el-tag>
          </a-space>`,
            setup(props: any) {
              let val = ref()
              val = props.params.data.machineState
              return {
                val,
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '0'
                ? '待机'
                : params.value == '1'
                ? '调机'
                : params.value == '2'
                ? '开机'
                : params.value == '3'
                ? '停机'
                : params.value == '4'
                ? '维修'
                : params.value == '5'
                ? '保养'
                : params.value == '6'
                ? '待机'
                : ''
            },
          }
        }

        return obj
      })
      let a1 = [
        {
          showRowGroup: 'hide_def',
          headerName: '',
          checkboxSelection: true,
          headerCheckboxSelection: true,
          pinned: 'left',
          width: 50,
          resizable: false,
          filter: false,
          sortable: false,
          minWidth: 50,
          maxWidth: 50,
          lockPosition: 'left',
        },
      ]
      tc1 = a1.concat(tc1)
      const tableColumnsChecked = useTableColumn([
        {
          title: '公司',
          key: 'company',
          dataIndex: 'company',
          width: 150,
        },
        {
          title: '机台号',
          key: 'machineCode',
          dataIndex: 'machineCode',
          width: 150,
        },

        {
          title: '楼层',
          key: 'storey',
          dataIndex: 'storey',
          width: 150,
        },

        {
          title: '员工工号',
          key: 'empCode',
          dataIndex: 'empCode',
          width: 150,
        },

        {
          title: '员工名称',
          key: 'empName',
          dataIndex: 'empName',
          width: 150,
        },

        {
          title: '值机日期',
          key: 'dutyDate',
          dataIndex: 'dutyDate',
          width: 150,
        },

        {
          title: '创建人',
          key: 'createName',
          dataIndex: 'createName',
          width: 150,
        },
        {
          title: '创建时间',
          key: 'createTime',
          dataIndex: 'createTime',
          width: 150,
        },
        {
          title: '修改人',
          key: 'updateName',
          dataIndex: 'updateName',
          width: 150,
        },
        {
          title: '修改时间',
          key: 'updateTime',
          dataIndex: 'updateTime',
          width: 150,
        },
        {
          title: '值机班次',
          key: 'shift',
          dataIndex: 'shift',
          width: 100,
          slotName: 'shift',
          fixed: 'right',
        },
        {
          title: '操作',
          key: 'id',
          dataIndex: 'id',
          slotName: 'action',
          width: 150,
          fixed: 'right',
        },
      ])

      let tc2: any[] = tableColumnsChecked.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          tooltipField: o.key,
        }
        if (o.slotName === 'action') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          obj['width'] = 210
          obj['lockPosition'] = 'right'
          obj['cellRenderer'] = {
            template: `<a-space><el-button :style="{color:isConfirmDisabled2?'#999':'#165dff'}" link @click="a"  v-if="e&&c!=1" :disabled="isConfirmDisabled2" >班长确认</el-button>
            <el-button type="info" link disabled  v-if="e&&c==1">班长确认</el-button>
            <el-button :style="{color:isEditDisabled2?'#999':'#165dff'}" link  @click="b" v-if="c!=1" :disabled="isEditDisabled2">修改</el-button>
            <el-button type="info" link disabled  v-if="e&&c==1">修改</el-button>
            <el-button :style="{color:isDetailDisabled2?'#999':'#165dff'}" link  @click="d" :disabled="isDetailDisabled2">详情</el-button>
            <el-button :style="{color:isReturnDisabled2?'#999':'#165dff'}" link  @click="f" :disabled="isReturnDisabled2">驳回</el-button></a-space>`,
            setup(props: any) {
              const a = () => {
                editHandler(props.params.data, 1)
              }
              const b = () => {
                editHandler(props.params.data, 2)
              }
              const d = () => {
                editHandler(props.params.data, 3)
              }
              const f = () => {
                rejecteds(props.params.data)
              }
              return {
                e: permissionStore.hasPermisson('zjpg.yzjxq'),
                c: props.params.data.dutyState,
                a,
                d,
                b,
                f,
                isDetailDisabled2,
                isEditDisabled2,
                isReturnDisabled2,
                isConfirmDisabled2,
              }
            },
          }
        }
        if (o.slotName === 'shift') {
          obj['resizable'] = false
          obj['sortable'] = false
          obj['width'] = 105
          obj['lockPosition'] = 'right'
          obj['cellRenderer'] = {
            template: `<a-space>  <el-tag  type="warning" v-if="c==1">{{val}}</el-tag>
                    <el-tag type="success" v-else>{{val}}</el-tag></a-space>`,
            setup(props: any) {
              let val = ref()
              if (props.params.data.shift == 1) {
                val.value = '晚班'
              } else {
                val.value = '白班'
              }
              return {
                val,
                c: props.params.data.shift,
              }
            },
          }
          obj['filterParams'] = {
            valueFormatter: function (params: any) {
              return params.value == '0' ? '白班' : params.value == '1' ? '晚班' : ''
            },
          }
        }
        return obj
      })

      let a2 = [
        {
          showRowGroup: 'hide_def',
          headerName: '',
          checkboxSelection: true,
          headerCheckboxSelection: true,
          pinned: 'left',
          width: 50,
          resizable: false,
          filter: false,
          sortable: false,
          minWidth: 50,
          maxWidth: 50,
          lockPosition: 'left',
        },
      ]
      tc2 = a2.concat(tc2)

      const pageData = reactive<{
        showAdd: boolean
        sideTitle: string
        dutymachineCode: any
        greyCode: any
        grayName: any
        planOrderCode: any
        weaveCode: any
        storey: any
        dutymachineDate: any[]
        dutymachineDate1: any[]
        pageLoading: boolean
        rHeight: any
        dutymachineState: number | undefined
        checkHeadList: any[]
        checkBodyList: any[]
        bodyValueList: any[]
        dataList: any[]
        machineCodeOb: {}
        getList: any[]
        dropDownList: any[]
        tcDutymachineCode: any
        tcStorey: any
        tcDutymachineCodeList: any[]
        tcStoreyList: any[]
        ygType: any
        ygName: any
        ygTypeList: any[]
        ygNameList: any[]
        firmList: any[]
        firmId: any
        isShow: boolean
        isShow1: boolean
        filterList: any[]
        editYgTime: any[]
        employeeId: any
        employeeName: string | undefined
        NowDate: any
        dutymachineId: any
        dateStart: any
        dateEnd: any
        applyBranchId: any
        isDetails: boolean
        shift: any
        date: any
        dataList3: any[]
        baiEmpId: any
        wanEmpId: any
        EmpList: any[]
        EmpId: any
        shift2: any
        date2: any
        rowData4: any[]
        adjustmentCode: any
        btnList: any[]
        xqDataList: any[]
        shift3: any
        date3: any
        title1: any
        EmpList1: any[]
        empName: any
        empCode: any
        empId: any
        showAddZJ: any
      }>({
        empCode: '',
        empId: '',
        empName: '',
        EmpList1: [],
        title1: '',
        showAdd: false,
        sideTitle: '新增值机派工',
        dutymachineCode: '',
        greyCode: '',
        grayName: '',
        planOrderCode: '',
        weaveCode: '',
        storey: '',
        dutymachineDate: [],
        dutymachineDate1: [],
        pageLoading: false,
        rHeight: '',
        dutymachineState: 0,
        checkHeadList: [],
        checkBodyList: [],
        bodyValueList: [],
        dataList: [],
        machineCodeOb: {},
        getList: [],
        dropDownList: [],
        tcDutymachineCode: '',
        tcStorey: '',
        tcDutymachineCodeList: [],
        tcStoreyList: [],
        ygType: '',
        ygName: '',
        ygTypeList: [],
        ygNameList: [],
        firmList: [],
        firmId: null,
        isShow: true,
        isShow1: true,
        filterList: [],
        editYgTime: [],
        employeeId: null,
        employeeName: '',
        NowDate: '',
        dutymachineId: null,
        dateStart: '',
        dateEnd: '',
        applyBranchId: '',
        isDetails: false,
        shift: null,
        date: null,
        dataList3: [],
        baiEmpId: null,
        wanEmpId: null,
        EmpList: [],
        EmpId: null,
        shift2: null,
        date2: null,
        rowData4: [],
        adjustmentCode: null,
        btnList: [],
        xqDataList: [],
        shift3: null,
        date3: null,
        showAddZJ: false,
      })

      onMounted(() => {
        updateGridState01()
        updateGridState02()
        if (tableId.value === 1) {
          getWzjPermission()
        } else if (tableId.value === 2) {
          getYzjPermission()
        }
      })
      //查询
      const selectHandler = () => {
        loadings.value = true
        if (tableId.value == 1) {
          pagination.page = 1
          doRefresh()
        } else if (tableId.value == 2) {
          paginations.page = 1
          doRefresh2()
        }
      }

      let loadings = ref(false)
      const dataForm = reactive<ClothInfo>({
        id: null,
        companyId: null,
        company: null,
        machineCode: null,
        storey: null,
        empId: null,
        empCode: null,
        empName: null,
        dutyDate: null,
        shift: null,
        dutyState: null,
        pieceDataState: null,
        createName: null,
        createTime: null,
        updateName: null,
        updateTime: null,
        departmentName: '',
        departmentId: '',
      })

      // 表格准备事件
      const gridOption = ref()
      const colState = ref()
      const gridReady = (params: any) => {
        gridOption.value = params.api
        colState.value = params.columnApi
      }
      // 表格准备事件
      const gridOption2 = ref()
      const colState2 = ref()
      const gridReady2 = (params: any) => {
        gridOption2.value = params.api
        colState2.value = params.columnApi
      }
      // 表格准备事件
      const gridOption3 = ref()
      const gridReady3 = (params: any) => {
        gridOption3.value = params.api
      }
      // 表格准备事件
      const gridOption4 = ref()
      const gridReady4 = (params: any) => {
        gridOption4.value = params.api
      }

      const formRef = ref<FormInstance>()
      const formRef1 = ref<FormInstance>()
      const formRef2 = ref()
      const sideOk = () => {
        // formRef1.value?.validate().then((err) => {
        //   if (!err) {
        if (pageData.empName == '' || pageData.empName == null || pageData.empName == undefined) {
          Message.error('请填写员工信息!')
          return
        } else {
          let machineList = []
          machineList = pageData.dataList3.map(function (o: any) {
            return { machineCode: o['machineCode'], storey: o['storey'] }
          })

          if (pageData.shift2 == 0) {
            pageData.wanEmpId = null
          } else {
            ;(pageData.wanEmpId = pageData.baiEmpId), (pageData.baiEmpId = null)
          }
          gridOption.value.getSelectedRows().forEach(function (o: any) {
            o['empId'] = pageData.shift2 == 0 ? pageData.baiEmpId : pageData.wanEmpId
            o['dutyDate'] = pageData.date2
            o['shift'] = pageData.shift2
            o['departmentId'] = dataForm.departmentId
            o['departmentName'] = dataForm.departmentName
          })
          const allIdsAreZero = pageData.dataList3.every((row: any) => row.suspendState === 0)
          if (!allIdsAreZero) {
            Message.warning({
              content: '生产单已暂停，无法派工！',
              duration: 5000,
            })
            return
          }
          if (pageData.sideTitle == '修改') {
            console.log(gridOption2.value.getSelectedRows()[0], '2222222')
            post({
              url: 'planSingle/dutymachineMachine/updateById',
              data: gridOption2.value.getSelectedRows()[0],
            }).then((res) => {
              if (res.code == 200) {
                // formRef1.value?.resetFields()
                pageData.showAdd = false
                Message.success({
                  content: '保存成功！',
                  duration: 5000,
                })
                pageData.showAdd = false
                doRefresh2()
              } else {
                Message.error({
                  content: res.message,
                  duration: 5000,
                })
              }
            })
          } else if (pageData.sideTitle == '班长确认') {
            post({
              url: 'planSingle/dutymachineMachine/monitorConfirm',
              data: { id: gridOption2.value.getSelectedRows()[0].id },
            }).then((res) => {
              if (res.code == 200) {
                // formRef1.value?.resetFields()
                pageData.showAdd = false
                Message.success({
                  content: '保存成功！',
                  duration: 5000,
                })
                pageData.showAdd = false
                doRefresh2()
              } else {
                Message.error({
                  content: res.message,
                  duration: 5000,
                })
              }
            })
          } else if (pageData.sideTitle == '新增值机派工') {
            let obs = {
              name: pageData.empName,
              code: pageData.empCode,
              id: pageData.empId,
              departmentName: dataForm.departmentName,
              departmentId: dataForm.departmentId,
            }
            if (pageData.shift === 0) {
              pageData.wanEmpId = null
              pageData.baiEmpId = pageData.empId
            } else {
              // pageData.wanEmpId = pageData.baiEmpId,
              pageData.baiEmpId = null
              pageData.wanEmpId = pageData.empId
            }
            post({
              url: 'planSingle/dutymachineMachine/insert',
              data: {
                baiEmpId: pageData.baiEmpId,
                wanEmpId: pageData.wanEmpId,
                machineList: pageData.dataList3,
                dateList: [pageData.date],
                shift: pageData.shift,
              },
            }).then((res) => {
              if (res.code == 200) {
                visible.value = false
                Message.success({
                  content: '保存成功！',
                  duration: 5000,
                })
                pageData.showAdd = false
                if (
                  pageData.shift == '' ||
                  pageData.shift == null ||
                  pageData.date == '' ||
                  pageData.date == null
                ) {
                  return
                }
                doRefresh()
              } else {
                Message.error({
                  content: res.message,
                  duration: 5000,
                })
              }
            })
          }
        }

        //   }
        // })
      }

      //班长确认 修改
      const editHandler = (record: ClothInfo, num: any) => {
        loadings.value = true
        pageData.date2 = record.dutyDate
        pageData.shift2 = record.shift
        pageData.baiEmpId = record.empId
        pageData.empName = record.empName
        dataForm.departmentId = record.departmentId
        dataForm.departmentName = record.departmentName
        getUsers()
        post({
          url: 'planSingle/dutymachine/getListByMachine',
          data: {
            machineList: [record.machineCode],
            shift: record.shift,
            date: record.dutyDate,
          },
        }).then(({ code, data, message }: any) => {
          if (code === 200) {
            if (data.length == 0) {
              Message.warning({
                content: '暂无数据',
                duration: 5000,
              })
              //  doRefresh2()
            } else {
              pageData.dataList3 = data
              pageData.sideTitle = '班长确认'
              pageData.showAdd = true
              if (num == 2) {
                pageData.sideTitle = '修改'
              }
              if (num == 3) {
                pageData.sideTitle = '详情'
              }
            }
          } else {
            Message.error({
              content: message,
              duration: 5000,
            })
          }
        })
      }

      //值机派工弹窗
      const visible = ref(false)
      const handleClick = () => {
        if (gridOption.value.getSelectedRows().length == 0) {
          Message.warning({
            content: '请先勾选！',
            duration: 5000,
          })
          return
        }
        // const allIdsAreZero = gridOption.value.getSelectedRows().every((row:any) => row.suspendState === 0);
        // if(!allIdsAreZero){
        //   Message.warning({
        //     content: '生产单已暂停，无法派工！',
        //     duration: 5000,
        //   })
        //   return
        // }
        let flag = false
        gridOption.value.getSelectedRows().forEach(function (o: any) {
          if (gridOption.value.getSelectedRows()[0]['storey'] != o['storey']) {
            flag = true
          }
        })
        if (flag) {
          visible1.value = true
        } else {
          pageData.sideTitle = '新增值机派工'
          // visible.value = true
          pageData.date2 = pageData.date
          pageData.shift2 = pageData.shift
          pageData.empName = ''
          dataForm.departmentId = ''
          dataForm.departmentName = ''
          pageData.showAdd = true
          getUsers()
        }
        doRefresh3()
      }

      const handleCancel = () => {
        visible.value = false
        pageData.baiEmpId = null
      }
      // let tableId = 1
      let tableId: any = ref(1)
      const isDetailDisabled = ref<boolean>(true)
      const isDetailDisabled2 = ref<boolean>(true)
      const isReturnDisabled2 = ref<boolean>(true)
      const isConfirmDisabled2 = ref<boolean>(true)
      const isEditDisabled2 = ref<boolean>(true)

      //获取未值机页签权限
      const getWzjPermission = () => {
        if (permissionStore.hasPermisson('zjpg.wzjcx')) {
          pageData.btnList.push('查询')
        }
        if (permissionStore.hasPermisson('zjpg.wzjpg')) {
          pageData.btnList.push('派工')
        }
        if (permissionStore.hasPermisson('zjpg.wzjxq')) {
          isDetailDisabled.value = false
        }
      }
      //获取已值机页签权限
      const getYzjPermission = () => {
        if (permissionStore.hasPermisson('zjpg.yzjcx')) {
          pageData.btnList.push('查询')
        }
        if (permissionStore.hasPermisson('zjpg.yzjbzqd')) {
          isConfirmDisabled2.value = false
        }
        if (permissionStore.hasPermisson('zjpg.yzjxq')) {
          isDetailDisabled2.value = false
        }
        if (permissionStore.hasPermisson('zjpg.yzjbh')) {
          //已值机驳回权限
          isReturnDisabled2.value = false
        }
        if (permissionStore.hasPermisson('zjpg.yzjxg')) {
          //已值机修改权限
          isEditDisabled2.value = false
        }
      }
      //已值机 未值机tab切换
      const changeTabs = (key: any) => {
        pageData.btnList = []
        tableId.value = key
        if (key == 1) {
          //未值机
          getWzjPermission()
          if (
            pageData.shift == '' ||
            pageData.shift == null ||
            pageData.date == '' ||
            pageData.date == null
          ) {
            return
          }
          pagination.page = 1
          pageData.dutymachineState = 0
          doRefresh()
        } else if (key == 2) {
          //已值机
          getYzjPermission()
          paginations.page = 1
          pageData.dutymachineState = 1
          doRefresh2()
          if (pageData.btnList.includes('派工')) {
            pageData.btnList = pageData.btnList.filter(function (o: any) {
              return o != '派工'
            })
          }
        }
      }
      //弹出员工框
      const visible1 = ref(false)

      const handleCancel1 = () => {
        visible1.value = false
      }
      //弹出详情
      const visible2 = ref(false)

      const handleCancel2 = () => {
        visible2.value = false
      }
      //设置权限
      // ['查询', '新增', '删除', '导出', '导入']
      const permissionStore = usePermission()

      const defaultColDef = {
        sortable: true,
        resizable: true,
        filter: true,
        // flex: 1
      }
      const defaultColDef22 = {
        sortable: true,
        resizable: true,
        filter: true,
        flex: 1,
      }
      const defaultColDef3 = {
        sortable: true,
        resizable: true,
        filter: true,
        // flex: 1
      }

      const localeText1: any = ref(localeText)
      const huiche = () => {
        doRefresh()
      }
      const pagingList1: any = ref(pagingList)
      const tableColumns3 = useTableColumn([
        {
          title: '工单号',
          key: 'dutymachineCode',
          dataIndex: 'dutymachineCode',
          width: 100,
        },
        {
          title: '机台号',
          key: 'machineCode',
          dataIndex: 'machineCode',
          width: 100,
        },
        {
          title: '生产单号',
          key: 'weaveCode',
          dataIndex: 'weaveCode',
          width: 100,
        },
        {
          title: '织布单号',
          key: 'planOrderCode',
          dataIndex: 'planOrderCode',
          width: 100,
        },
        {
          title: '坯布编号',
          key: 'greyCode',
          dataIndex: 'greyCode',
          width: 100,
        },

        {
          title: '坯布名称',
          key: 'grayName',
          dataIndex: 'grayName',
          width: 100,
        },

        {
          title: '客户名称',
          key: 'customName',
          dataIndex: 'customName',
          width: 100,
        },

        {
          title: '楼层',
          key: 'storey',
          dataIndex: 'storey',
          width: 100,
        },

        {
          title: '日期',
          key: 'schedulDate',
          dataIndex: 'schedulDate',
          width: 100,
        },
        {
          title: '暂停状态',
          key: 'suspendState',
          dataIndex: 'suspendState',
          slotName: 'suspendState',
          width: 100,
        },
        {
          title: '暂停时间',
          key: 'suspendTime',
          dataIndex: 'suspendTime',
          width: 100,
        },
        {
          title: '暂停人',
          key: 'suspendName',
          dataIndex: 'suspendName',
          width: 100,
        },
      ])
      let tc3: any[] = tableColumns3.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          tooltipField: o.key,
        }
        if (o.slotName === 'suspendState') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          obj['lockPosition'] = 'left'
          ;(obj['width'] = 120),
            (obj['cellRenderer'] = {
              template: `
      <el-tag v-if="a==0" type="success">未暂停</el-tag>
      <el-tag v-if="a==1" type="warning">等待暂停</el-tag>
      <el-tag v-if="a==2" type="warning">生产中暂停</el-tag>
        `,
              setup(props: any) {
                return {
                  a: props.params.data.suspendState,
                }
              },
            })
        }
        return obj
      })

      //值机弹窗保存
      function saveZjData() {
        //判断是否选了员工
        formRef2.value?.validate().then((err: any) => {
          if (!err) {
            // let machineList = []
            // machineList = pageData.dataList3.map(function (o: any) {
            //   return { "machineCode": o['machineCode'], "storey": o['storey'] }
            // })

            if (pageData.shift === 0) {
              pageData.wanEmpId = null
            } else {
              ;(pageData.wanEmpId = pageData.baiEmpId), (pageData.baiEmpId = null)
            }
            post({
              url: 'planSingle/dutymachineMachine/insert',
              data: {
                baiEmpId: pageData.baiEmpId,
                wanEmpId: pageData.wanEmpId,
                machineList: pageData.dataList3,
                dateList: [pageData.date],
                shift: pageData.shift,
              },
            }).then((res) => {
              if (res.code == 200) {
                visible.value = false
                Message.success({
                  content: '保存成功！',
                  duration: 5000,
                })
                if (
                  pageData.shift == '' ||
                  pageData.shift == null ||
                  pageData.date == '' ||
                  pageData.date == null
                ) {
                  return
                }
                doRefresh()
              } else {
                Message.error({
                  content: res.message,
                  duration: 5000,
                })
              }
            })
          }
        })
      }
      //查询员工
      function getUsers() {
        post({
          url: 'org/baCompany/getDepartmentTreeByUserTop',
          data: {},
        }).then((res) => {
          if (res.code == 200) {
            pageData.EmpList = res.data
          } else {
            Message.error({
              content: res.message,
              duration: 5000,
            })
          }
        })
      }

      //设置权限
      // ['查询', '新增', '删除', '导出', '导入']

      // if (permissionStore.hasPermisson('zjpg.yzjcx')) {
      //   pageData.btnList.push('查询')
      // }
      // if (permissionStore.hasPermisson('zjpg.pg') && tableId.value == 1) {
      //   pageData.btnList.push('派工')
      // }
      let selectKeys = ref([])
      const tableColumnsXq = useTableColumn([
        {
          title: '织布单号',
          key: 'planOrderCode',
          dataIndex: 'planOrderCode',
          width: 130,
        },
        // {
        //   title: '指令重量',
        //   key: 'orderWeight',
        //   dataIndex: 'orderWeight',
        //   width: 120,
        // },
        {
          title: '生产单号',
          key: 'weavingCode',
          dataIndex: 'weavingCode',
          width: 120,
        },
        {
          title: '分配重量',
          key: 'alreadyWeight',
          dataIndex: 'alreadyWeight',
          width: 120,
        },
        {
          title: '坯布编号',
          key: 'greyCode',
          dataIndex: 'greyCode',
          width: 120,
        },
        {
          title: '坯布名称',
          key: 'greyName',
          dataIndex: 'greyName',
          width: 250,
        },
      ])
      //打开详情弹窗
      function openPop2(data: any) {
        post({
          url: 'planSingle/planMachineTask/getList',
          data: {
            // machineList: [data.machineCode],
            shift: pageData.shift,
            machineCode: data.machineCode,
            storey: data.storey,
            date: pageData.date,
            neState: 1,
          },
        })
          .then(({ data, code, message }: any) => {
            if (code === 200) {
              pageData.dataList3 = data
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
            }
          })
          .catch(console.log)
          .finally(() => {})
        visible2.value = true
      }
      const { saveGridState: saveGridState01, updateGridState: updateGridState01 } =
        saveOrUpdateGridState01('CheckDispatch-1', gridOption, colState, tc1)
      const onColumnMoved = () => {
        saveGridState01()
      }
      const onColumnResized = () => {
        saveGridState01()
      }
      const onColumnVisible = () => {
        saveGridState01()
      }
      const { saveGridState: saveGridState02, updateGridState: updateGridState02 } =
        saveOrUpdateGridState02('CheckDispatch-1-2', gridOption2, colState2, tc2)
      const onColumnMoved2 = () => {
        saveGridState02()
      }
      const onColumnResized2 = () => {
        saveGridState02()
      }
      const onColumnVisible2 = () => {
        saveGridState02()
      }
      const casOb1 = ref()
      const cascaderChange1 = (val: any) => {
        dataForm.departmentName = ''
        pageData.empName = ''
        //拿到选中的这个节点数组
        setTimeout(function () {
          if (casOb1.value.selectViewValue.length != 0) {
            pageData.title1 = slicing(casOb1.value.selectViewValue[0]['label'])
            dataForm.departmentName = slicing(casOb1.value.selectViewValue[0]['label'])
          }
        }, 100)
        // console.log(val)

        // console.log(pageData.EmpList1)
        // processChildren(pageData.EmpList);
      }
      function processChildren(arr: any) {
        arr.forEach((item: any) => {
          if (Array.isArray(item.children)) {
            if (item.children == '' || item.children == null || item.children == undefined) {
              if (item.value == dataForm.departmentId) {
                if (
                  item.employeeList == '' ||
                  item.employeeList == null ||
                  item.employeeList == undefined
                ) {
                  pageData.EmpList1 = []
                } else {
                  pageData.EmpList1 = item.employeeList
                }
              }
            } else {
              processChildren(item.children)
            }
          }
        })
        console.log(pageData.EmpList1)
      }
      const changeEmp = () => {
        pageData.EmpList1.forEach((item: any) => {
          if (pageData.empName == item.name) {
            // pageData.baiEmpId = item.id
            pageData.empId = item.id
            pageData.empCode = item.code
          }
        })
      }
      const getUsers1 = () => {
        post({
          url: 'org/hrEmployee/getUserAndSecondment',
          data: {
            department_id: dataForm.departmentId,
            workTime: pageData.date2,
            shift: pageData.shift2,
          },
        }).then(({ data, code }: any) => {
          if (code === 200) {
            pageData.EmpList1 = data
          } else {
            Message.error({
              content: '该部门无员工信息！',
              duration: 5000,
            })
          }
        })
      }
      const rejecteds = (res: any) => {
        Modal.confirm({
          title: '系统提示',
          content: '确认驳回选中的数据?',
          onOk() {
            post({
              url: '/planSingle/dutymachineMachine/deleteList',
              data: [res.id],
            }).then(({ code, data, message }: any) => {
              if (code === 200) {
                Message.success({
                  content: message,
                  duration: 5000,
                })

                pagination.page = 1
                doRefresh2()
              } else {
                Message.error({
                  content: message,
                  duration: 5000,
                })
              }
            })
          },
        })
      }
      const goContinue = () => {
        visible.value = true
        visible1.value = false
      }
      return {
        getUsers1,
        changeEmp,
        processChildren,
        casOb1,
        cascaderChange1,
        saveOrUpdateGridState01,
        saveGridState01,
        updateGridState01,
        onColumnMoved,
        onColumnResized,
        onColumnVisible,
        colState,
        saveOrUpdateGridState02,
        saveGridState02,
        updateGridState02,
        onColumnMoved2,
        onColumnResized2,
        onColumnVisible2,
        colState2,
        tableColumnsXq,
        gridOption4,
        selectKeys,
        gridReady4,
        getUsers,
        formRef2,
        saveZjData,
        formRef1,
        gridOption3,
        gridReady3,
        tc3,
        tableColumns3,
        rejecteds,
        tableId,
        pagingList1,
        huiche,
        localeText1,
        paginations,

        defaultColDef,
        defaultColDef3,
        tc1,
        tc2,
        gridOption,
        gridOption2,
        gridReady,
        gridReady2,
        sideOk,
        formRef,
        dataForm,
        selectedRowKeys,
        s: selectedRowKeysChecked.selectedRowKeys,
        pagination,
        tableColumns,
        table,
        rowKey,
        pageData,
        pageData1,
        editHandler,
        selectHandler,
        tableColumnsChecked,
        changeTabs,
        handleClick,
        handleCancel,
        visible,
        headerShow,
        visible1,
        handleCancel1,
        visible2,
        handleCancel2,
        permissionStore,
        configCascader,
        changeCascader,
        change1,
        PageSize,
        cascaderRef,
        defaultColDef22,
        goContinue,
        getWzjPermission,
        isDetailDisabled,
        isDetailDisabled2,
        isConfirmDisabled2,
        isReturnDisabled2,
        isEditDisabled2,
        aggridFs,
        aggridFs1,
      }
    },
    components: { Toolbar, PageTabelLayout, CorporateSectorCascader },
  }
</script>
<style scoped>
  #Table td,
  #Table th {
    border: 1px solid #ccc;
    padding: 10px;
  }

  .tdStyle {
    min-width: 100px;
  }

  .notClick {
    background-color: gray;
    cursor: no-drop;
  }

  :deep(.SendCheck) {
    z-index: 100 !important;
  }

  :deep(.arco-table-th) {
    border-right: 1px solid var(--color-neutral-3);
  }

  :deep(.arco-table-td) {
    border-right: 1px solid var(--color-neutral-3);
  }
</style>
